﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace RapChieuPhim.GUI
{
    public partial class LichChieuGUI : UserControl
    {
        public LichChieuGUI()
        {
            InitializeComponent();
        }

        private void LoadData()
        {
            gridControlMain.DataSource = BUS.CTPhongBUS.GetAll();
        }

        private void navBarItem6_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            colNgay.GroupIndex = -1;
            colRap.GroupIndex = -1;
            colPhim.GroupIndex = -1;
        }

        private void navBarItem3_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            navBarItem6_LinkClicked(null, null);
            colNgay.GroupIndex = 0;
        }

        private void navBarItem4_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            navBarItem6_LinkClicked(null, null);
            colPhim.GroupIndex = 0;
        }

        private void navBarItem5_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            navBarItem6_LinkClicked(null, null);
            colRap.GroupIndex = 0;
        }

        private void LichChieuGUI_Load(object sender, EventArgs e)
        {
            LoadData();
        }

        private void navBarItem1_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            gridControlMain.ShowPrintPreview();
        }

        private void navBarItem2_LinkClicked(object sender, DevExpress.XtraNavBar.NavBarLinkEventArgs e)
        {
            SaveFileDialog _dialog = new SaveFileDialog();
            _dialog.InitialDirectory = Application.StartupPath.ToString();
            _dialog.Title = "Xuất ra file pdf";
            _dialog.DefaultExt = "pdf";
            _dialog.Filter = "All files (*.*)|*.*";
            _dialog.FilterIndex = 0;
            _dialog.RestoreDirectory = true;
            if (_dialog.ShowDialog() == DialogResult.OK)
            {
                gridControlMain.ExportToPdf(_dialog.FileName.ToString());

                System.Diagnostics.Process _prc = new System.Diagnostics.Process();
                _prc.StartInfo.FileName = System.IO.Path.GetDirectoryName(_dialog.FileName);
                _prc.Start();
            }
        }
    }
}
